<template>
  <div
    class="couponBox"
    :class="{colorGlod : isSelect}"
    :title="couponItem.content"
  >
    <SvgIcon
      class="svg-icon"
      :name="isSelect ? 'coupon-selected' : 'coupon-unselected'"
    />
    <div class="des">
      <div class="nums" v-if="couponItem.couponType === 1">
        ¥ <span class="money">{{ couponItem.reduceMoney || 0 }}</span>
      </div>
      <div class="nums" v-if="couponItem.couponType === 2">
        <span class="money">{{ couponItem.reduceMoney || 0 }}</span>折
      </div>
      <div class="cloumn" v-if="couponItem.couponType === 1">
        <!-- <div v-if="couponItem.type === 1">平台券</div> -->
        <!-- <div v-if="couponItem.type === 2">商家券</div> -->
        <div>{{ type }}</div>
        <span>{{ couponItem.content }}</span>
      </div>
      <div class="cloumn" v-if="couponItem.couponType === 2">
        <div>{{ type }}</div>
        <span v-if="couponItem.fullMoney">
          满{{ couponItem.fullMoney }}元打{{ couponItem.reduceMoney }}折
        </span>
        <span v-else>{{ couponItem.content }}</span>
      </div>
    </div>
    <div class="aside" @click="chooseCoupon(couponItem)">
      <SvgIcon
        style="width: 20px; height: 20px;"
        :name="isSelect ? 'pay-checked' : 'pay-unchecked'"
      />
    </div>
  </div>
</template>

<script setup>
import { defineComponent, toRefs } from 'vue';
import SvgIcon from '@/components/svgIcon/index.vue';
defineComponent({
  name: 'PlaceOrderCouponBox'
})
const props = defineProps({
  couponItem: {
    type: Object,
    default: () => ({})
  },
  type: String,
  isSelect: {
    type: Boolean,
    default: false
  }
})
let { couponItem, type, isSelect } = toRefs(props);

const emit = defineEmits(['couponSelect'])
function chooseCoupon (item) {
  emit('couponSelect', item)
}
</script>

<style lang="scss" scoped>
.colorGlod{
  color: #FFEBC4;
}
.couponBox{
  width: 100%;
  height: 100%;
  display: flex;
  .svg-icon{
    width:100%;
    height:100%;
    position: absolute;
    z-index: -1;
  }
  .des{
    margin-left: 5px;
    flex: 9;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    .nums{
      flex: 5;
      text-align: right;
      .money{
        font-size: 32px;
      }
    }
    .cloumn{
      flex: 5;
      height: 35px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      margin-left: 8px;
      font-size: 12px;
      span{
        max-width: 70px;
        white-space: nowrap;
        overflow: hidden;
      }
    }
  }
  .aside{
    flex: 2;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .marginR{
    margin-right: 100px;
  }
}
</style>
